﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Base="clr-namespace:Corina.Cydee.Apphub.Base"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:navigation="clr-namespace:Corina.Cydee.Apphub.Base"
                    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                    mc:Ignorable="d">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml" />
        <ResourceDictionary Source="../Converters.xaml" />
        <ResourceDictionary Source="../Icons.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="TopurlItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid Width="72"
                          Height="48"
                          Margin="0,6,6,6">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="12" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates" ei:ExtendedVisualStateManager.UseFluidLayout="True">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.4" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="SelectedUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundGrid" Storyboard.TargetProperty="(FrameworkElement.Width)">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Double>72</System:Double>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ColorAnimation Duration="0"
                                                        Storyboard.TargetName="path"
                                                        Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                        To="White"
                                                        d:IsOptimized="True" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unselected" />
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundGrid" Storyboard.TargetProperty="(FrameworkElement.Width)">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Double>72</System:Double>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ColorAnimation Duration="0"
                                                        Storyboard.TargetName="path"
                                                        Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                        To="White"
                                                        d:IsOptimized="True" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <VisualStateManager.CustomVisualStateManager>
                            <ei:ExtendedVisualStateManager />
                        </VisualStateManager.CustomVisualStateManager>
                        <Grid x:Name="backgroundGrid"
                              Grid.ColumnSpan="2"
                              Width="12"
                              HorizontalAlignment="Left"
                              Background="{StaticResource HighlightBrush}"
                              Visibility="Collapsed" />
                        <Grid Grid.ColumnSpan="2"
                              Background="White"
                              Opacity="0" />
                        <Grid Grid.Column="1"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center">
                            <Path x:Name="path"
                                  Width="36"
                                  Height="36"
                                  Margin="0"
                                  Data="{Binding Icon,
                                                 Converter={StaticResource KeyToPathGeometryConverter}}"
                                  Fill="Gray"
                                  RenderTransformOrigin="0.5,0.5"
                                  Stretch="Uniform">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <RotateTransform Angle="0" />
                                        <ScaleTransform ScaleX="1" ScaleY="1" />
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LeftToRightItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>
                        <sdk:Label Content="{Binding Title}" />

                        <Button Grid.Column="1" Style="{StaticResource SwapRightButtonStyle}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RightToLeftItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <sdk:Label Grid.Column="1" Content="{Binding Title}" />

                        <Button Style="{StaticResource SwapLeftButtonStyle}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RoleListitemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetName="editbutton"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="fillColor"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To=".55" />
                                        <ColorAnimation Duration="0"
                                                        Storyboard.TargetName="contentControl"
                                                        Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                                                        To="{StaticResource HoverForegroundColor}" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="contentPresenter"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To=".55" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected" />
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetName="editbutton"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ColorAnimation Duration="0"
                                                        Storyboard.TargetName="contentControl"
                                                        Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                                                        To="{StaticResource HoverForegroundColor}" />
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="fillColor"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SelectedUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetName="editbutton"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ColorAnimation Duration="0"
                                                        Storyboard.TargetName="contentControl"
                                                        Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                                                        To="{StaticResource HoverForegroundColor}" />
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="fillColor"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="1" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetName="FocusVisualElement"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="fillColor2"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="1" />
                                        <ColorAnimation Duration="0"
                                                        Storyboard.TargetName="contentControl"
                                                        Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                                                        To="{StaticResource HoverForegroundColor}" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="fillColor"
                                   Fill="{StaticResource HighlightBrush}"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   RadiusX="1"
                                   RadiusY="1" />
                        <Rectangle x:Name="fillColor2"
                                   Fill="{StaticResource HighlightBrush}"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   RadiusX="1"
                                   RadiusY="1" />
                        <ContentControl x:Name="contentControl" HorizontalContentAlignment="Stretch">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <ContentPresenter x:Name="contentPresenter"
                                                  Margin="7"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="Center"
                                                  Content="{Binding Name}" />
                                <Button x:Name="editbutton"
                                        Grid.Column="1"
                                        Visibility="Collapsed">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <i:InvokeCommandAction Command="{Binding Path=DataContext.EditCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=Base:PageView}}" CommandParameter="{Binding Id}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                    <Button.Style>
                                        <Style TargetType="Button">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Grid>
                                                            <Rectangle Fill="White" Opacity="0" />
                                                            <Path Width="18"
                                                                  Height="18"
                                                                  Margin="12,0"
                                                                  Data="{Binding Converter={StaticResource StringToPathGeometryConverter},
                                                                                 Source={StaticResource ICON_EDIT}}"
                                                                  Fill="#FFFFFFFF"
                                                                  RenderTransformOrigin="0.5,0.5"
                                                                  Stretch="Uniform">
                                                                <Path.RenderTransform>
                                                                    <TransformGroup>
                                                                        <RotateTransform Angle="0" />
                                                                        <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                    </TransformGroup>
                                                                </Path.RenderTransform>
                                                            </Path>
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Button.Style>
                                </Button>
                            </Grid>
                        </ContentControl>
                        <Rectangle x:Name="FocusVisualElement"
                                   RadiusX="1"
                                   RadiusY="1"
                                   Stroke="{StaticResource HighlightBrush}"
                                   StrokeThickness="1"
                                   Visibility="Collapsed" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DeviceMessageItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="6" />
                            <ColumnDefinition Width="12" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <StackPanel Grid.RowSpan="2"
                                    Margin="12,0"
                                    VerticalAlignment="Center">
                            <TextBlock HorizontalAlignment="Right"
                                       FontSize="14"
                                       Text="00-00" />
                            <TextBlock HorizontalAlignment="Right"
                                       FontSize="14"
                                       Text="00:00" />
                        </StackPanel>

                        <Border Grid.Column="1"
                                Margin="0,0,0,6"
                                Background="{StaticResource DisbaledForegroundBrush}"
                                CornerRadius="0,0,3,3" />
                        <Ellipse Grid.RowSpan="2"
                                 Grid.Column="1"
                                 Width="6"
                                 Height="6"
                                 Fill="{StaticResource DisbaledForegroundBrush}" />
                        <Border Grid.Row="1"
                                Grid.Column="1"
                                Margin="0,6,0,0"
                                Background="{StaticResource DisbaledForegroundBrush}"
                                CornerRadius="3,3,0,0" />
                        <Border Grid.Row="2"
                                Grid.Column="1"
                                MinHeight="20"
                                Background="{StaticResource DisbaledForegroundBrush}" />

                        <Path Grid.RowSpan="2"
                              Grid.Column="2"
                              Width="12"
                              Height="16"
                              Margin="0,0,-4,0"
                              Data="M582.309,226.984L547.355,194.984 582.309,162.984 582.309,226.984z"
                              Fill="{StaticResource DisbaledForegroundBrush}"
                              RenderTransformOrigin="0.5,0.5"
                              Stretch="Uniform">
                            <Path.Effect>
                                <DropShadowEffect ShadowDepth="0" />
                            </Path.Effect>
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform Angle="0" />
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>

                        <Grid Grid.RowSpan="3"
                              Grid.Column="3"
                              Margin="0,6,12,3"
                              Background="{StaticResource DisbaledForegroundBrush}">
                            <Grid.Effect>
                                <DropShadowEffect ShadowDepth="0" />
                            </Grid.Effect>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <HyperlinkButton Content="{Binding DeviceSn}" />
                                    <TextBlock Text="：" />
                                    <TextBlock Text="{Binding Kind}" />
                                </StackPanel>
                                <TextBlock Margin="0,6" Text="{Binding Content}" />
                                <StackPanel Orientation="Horizontal">
                                    <HyperlinkButton Content="解析" />
                                    <HyperlinkButton Content="删除" />
                                </StackPanel>
                            </StackPanel>
                        </Grid>

                    </Grid>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="UserItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <StackPanel Margin="6">
                        <Grid HorizontalAlignment="Center">
                            <Path Width="36"
                                  Height="36"
                                  Margin="0,0,0,0"
                                  Data="{Binding Source={StaticResource ICON_USER},
                                                 Converter={StaticResource StringToPathGeometryConverter}}"
                                  Fill="Gray"
                                  RenderTransformOrigin="0.5,0.5"
                                  Stretch="Uniform">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <RotateTransform Angle="0" />
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                            <Grid Width="16"
                                  Height="16"
                                  HorizontalAlignment="Right"
                                  VerticalAlignment="Bottom"
                                  Visibility="{Binding IsSelected,
                                                       Converter={StaticResource BooleanToVisibilityConverter},
                                                       RelativeSource={RelativeSource TemplatedParent}}">
                                <Ellipse Name="Fill"
                                         Fill="#FF484848"
                                         Visibility="Visible" />
                                <Path Width="8"
                                      Height="8"
                                      Margin="0,0,0,0"
                                      Data="{Binding Source={StaticResource ICON_CHECK},
                                                     Converter={StaticResource StringToPathGeometryConverter}}"
                                      Fill="#FFFFFFFF"
                                      RenderTransformOrigin="0.5,0.5"
                                      Stretch="Uniform">
                                    <Path.RenderTransform>
                                        <TransformGroup>
                                            <TransformGroup.Children>
                                                <RotateTransform Angle="0" />
                                                <ScaleTransform ScaleX="1" ScaleY="1" />
                                            </TransformGroup.Children>
                                        </TransformGroup>
                                    </Path.RenderTransform>
                                </Path>
                            </Grid>
                        </Grid>
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="UnsaledDeviceItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid Margin="6">
                        <Grid Background="White" Opacity="0" />
                        <StackPanel>
                            <Path Width="32"
                                  Height="32"
                                  Margin="6"
                                  HorizontalAlignment="Center"
                                  AllowDrop="True"
                                  Data="{Binding Source={StaticResource ICON_TOASTER}}"
                                  Fill="Gray"
                                  RenderTransformOrigin="0.5,0.5"
                                  Stretch="Uniform">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <RotateTransform Angle="0" />
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Path.RenderTransform>

                            </Path>
                            <TextBlock Text="{Binding DeviceSn}" />
                        </StackPanel>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MouseLeftButtonDown">
                                <i:InvokeCommandAction Command="{Binding Path=DataContext.MouseLeftButtonDownCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding DeviceSn}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <!--
                            <Interactivity:Interaction.Triggers>
                            <Interactivity:EventTrigger EventName="MouseLeftButtonDown">
                            <Interactions:CallMethodAction MethodName="{Binding Path=DataContext.OnMouseLeftButtonDown, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" TargetObject="{Binding}" />
                            </Interactivity:EventTrigger>
                            </Interactivity:Interaction.Triggers>
                        -->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
